﻿using System;
using System.Threading;
using Adaptive.Agrona.Concurrent;
using Unity.Commons.Client.Statistics;
using Unity.Credentials;
using Unity.Type;

namespace Unity.Debug.Examples
{
    class ConsoleOfflineMode
    {
        static void Main(string[] args)
        {
            string csiId = "143447";
            IMessageQueueCredentials messageQueueCredentials = new ConsoleMessageQueueCredentials();
            messageQueueCredentials.CsiId = 143447;
            IUnityCredentials unityCredentials = new ConsoleUnityCredentials();
            
            ConsoleUnityClient client = ConsoleUnityClientFactory.MakeUnityClient(messageQueueCredentials, unityCredentials, new ConsoleOfflineHandler());
            client.Connect(10000);

            UnsafeBuffer clientBuffer = new UnsafeBuffer(new byte[2048]);
            for(int i = 0; i < 100000; i++)
            {
                client.Generate(EntityType.Order, clientBuffer, 0);
                IUnityStatistics statistics = client.GetStatistics();
                long generated = statistics.GetGenerated();
            }
            Thread.Sleep(100000);
            client.Close();
            Console.WriteLine("Done");
        }
    }
}